﻿<Window x:Class="MusicExplorer.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:MusicExplorer.Resources.Control"
        xmlns:views="clr-namespace:MusicExplorer.View"
        xmlns:internals="clr-namespace:MusicExplorer.Internals"
        xmlns:sys="clr-namespace:System;assembly=System"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WPF4"
        xmlns:vm="clr-namespace:MusicExplorer.ViewModel"
        SizeChanged="WindowSizeChanged"
        Title="MusicExplorer" DataContext="{Binding MainWindow, Source={StaticResource Locator}}">
    
    <Window.Resources>
        <ResourceDictionary>
            <internals:WebRepositoryToDetailTreeVisibilityConverter x:Key="WebRepositoryToDetailTreeVisibilityConverter" />
            <internals:WebRepositoryAndItemToTrackListVisibilityConverter x:Key="WebRepositoryAndItemToTrackListVisibilityConverter" />
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        
        <!-- Player -->
        <views:Player HorizontalContentAlignment="Stretch" />

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
        
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <!-- Liste des repository -->
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <views:WebRepositoryTree />
            </Grid>
            
            <GridSplitter Height="Auto" IsEnabled="False" Grid.Column="1" HorizontalAlignment="Left" Focusable="False" Style="{StaticResource GridSplitterStyle}" />

            <!-- Liste des tracks -->
            <views:TrackList Grid.Column="2">
                <UserControl.Visibility>
                    <MultiBinding Converter="{StaticResource WebRepositoryAndItemToTrackListVisibilityConverter}" Mode="TwoWay">
                        <Binding Path="Parent.WebRepositoryTree.SelectedWebRepository" />
                        <Binding Path="Parent.DetailTree.SelectedItem" />
                    </MultiBinding>
                </UserControl.Visibility>
            </views:TrackList>

            <GridSplitter Height="Auto" IsEnabled="False" Grid.Column="3" HorizontalAlignment="Left" Focusable="False" Style="{StaticResource GridSplitterStyle}" />

            <views:DetailTree Grid.Column="4" Visibility="{Binding Parent.WebRepositoryTree.SelectedWebRepository, Converter={StaticResource WebRepositoryToDetailTreeVisibilityConverter}}" />
        </Grid>

        <views:Log DataContext="{Binding Log}" Grid.Row="2" />
    </Grid>
</Window>
